// Programming_Scala/src/ch07/http-script.scala

sealed abstract class HttpMethod()
case class Connect( body: String ) extends HttpMethod
case class Delete ( body: String ) extends HttpMethod
case class Get    ( body: String ) extends HttpMethod
case class Head   ( body: String ) extends HttpMethod
case class Options( body: String ) extends HttpMethod
case class Post   ( body: String ) extends HttpMethod
case class Put    ( body: String ) extends HttpMethod
case class Trace  ( body: String ) extends HttpMethod

def handle( method: HttpMethod ) = method match {
  case Connect ( body ) => println( "Connect: " + body )
  case Delete  ( body ) => println( "Delete: " + body )
  case Get     ( body ) => println( "Get: " + body )
  case Head    ( body ) => println( "Head: " + body )
  case Options ( body ) => println( "Options: " + body )
  case Post    ( body ) => println( "Post: " + body )
  case Put     ( body ) => println( "Put: " + body )
  case Trace   ( body ) => println( "Trace: " + body )
}

val methods = List(
  Connect( "connect body" ),
  Delete( "delete body" ),
  Get( "get body" ),
  Head( "head body" ),
  Options( "options body" ),
  Post( "post body" ),
  Put( "put body" ),
  Trace( "trace body" ) /* ,
  NoOp( "noop body" ) */
)

methods.foreach { method => handle( method ) }
